;; Additions to rst-mode capability 
;; for emacs 23.1 under windows
;; Assumes that docutils 
;; (http://docutils.sourceforge.net/) are present
;; Sets up firefox as the previewer
;; 8-19-2009  

;; Use firefox to preview rst-mode files on windows
(defvar rst-firefox-preview "c:/PROGRA~1/MOZILL~1/firefox.exe -new-tab"
"Program used to preview rst file in firefox.")

(defun rst-compile-windows-file-preview ()
  "Compile command to convert reST file 
   into html and preview it in firefox"
  (interactive)
  (let* ((tmp-filename "c:/tmp/out.html")
	 (tmp1-filename "file:///c:/tmp/out.html")
	 (command (format "rst2html %s %s && %s %s"
			  buffer-file-name tmp-filename
			  rst-firefox-preview tmp1-filename)))
    (start-process-shell-command "rst-firefox-preview" nil command)
    ;; Note: you could also use 
    ;; (compile command) to view the compilation
    ;; output.
    ))

;; add windows variant of rst-mode slide program
;; you can test it by loading the text file available at this URL 
;; <http://www.python.org/doc/slideshows/preparing-for-screencasting.txt>
;; remember to toggle rst-mode on (M-x rst-mode) prior to running the test!

(defun rst-compile-windows-slides-preview ()
  "Convert the document to an S5 slide presentation and launch a preview
 program. The original rst.el code has been adapted to work under windows"
  (interactive)
  (let* ((tmp-filename "c:/tmp/slides.html")
	 (tmp1-filename "file:///c:/tmp/slides.html")
	 (command (format "rst2s5.py %s %s && %s %s"
			  buffer-file-name tmp-filename
			  rst-firefox-preview tmp1-filename)))
    (start-process-shell-command "rst-firefox-preview" nil command)
    ;; Note: you could also use (compile command) to view the compilation
    ;; output.
    ))

;; add a new keybinding to rst-mode-map keymap 
;; enabling previewing of rst files (for windows)
;; Convert the active file to html and preview in 
;; firefox using the docutils tools.
;; 

(add-hook 'rst-mode-hook
	  (lambda ()
	    (define-key rst-mode-map [(control c) (?6)] 
	      'rst-compile-windows-file-preview)))

;; add a new keybinding to rst-mode-map keymap
;; enabling previewing of s5 slides (for windows)
;; Convert the active file to html and preview 
;; in firefox using the docutils tools.
;; Modified for use in windows


(add-hook 'rst-mode-hook
	  (lambda ()
	    (define-key rst-mode-map [(control c) (?7)]
	      'rst-compile-windows-slides-preview)))

